<template>
	<view class="container">
		<view class="first-item" v-for="(item,index) in gridList" :key="index">
			<view style="margin-top:2px">
				<view v-for="(gridItem,gridIndex) in item" :key="gridIndex">
					<view style="width:16px;height: 16px;border-radius: 8px;border: 1px solid #3E9CF9;color:#3E9CF9;font-size: 8px;text-align: center;line-height: 14px;"
					 v-if="gridIndex == 0">主</view>
					<view v-else>
						<view style="height:60upx;width:1px;border-left: 1px dashed #C4C4C4;margin-left: 8px;margin-top: 5upx;"></view>
						<view style="width:16px;height: 16px;border-radius: 8px;border: 1px solid #ff0000;color:#ff0000;font-size: 8px;text-align: center;line-height: 14px;margin-top:5upx">次</view>
					</view>
				</view>
			</view>
			<view style="margin-left:20upx;width:calc(100% - 100upx)">
				<view v-for="(gridItem,gridIndex) in item" :key="gridIndex">
					<view style="height:98upx">
						<view style="font-size: 14px;font-weight: bolder;">
							{{gridItem.gridName}}
						</view>
						<view style="font-size: 11px;line-height: 14px;color:#999999">
							{{gridItem.area}}㎡
						</view>
					</view>
					<view style="margin-top:20upx;font-size: 11px;line-height: 14px;color:#999999" v-if="gridIndex == (item.length - 1)">
						管理人员：{{gridItem.adminCount}}
					</view>
				</view>
			</view>
			<view>
				<view style="background: #3E9CF9;width: 20px;height:20px;line-height: 16px;border-radius: 10px;text-align: center;margin-top:20upx"
				 @click="navTo(item)">
					<text class="yticon icon-you" style="font-size: 10px;color:white"></text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				areaCode: this.$api.util.getAreaCode(),
				gridList: []
			}
		},
		onLoad() {
			this.initGridInfo()
		},
		methods: {
			initGridInfo() {
				let params = {
					areaCode: this.areaCode
				}
				this.$api.request.getAllParentGrids(params, (res) => {
					if (res.body.status.statusCode === '0') {
						this.gridList = res.body.data
					}
				})
			},
			navTo(item) {
				if (item.length > 0) {
					uni.navigateTo({
						url: "/package_isp/pages/grid/gridAdminManager?item=" + JSON.stringify(item)
					})
				}
			},
		}
	}
</script>

<style>
	page {
		background-color: #F8F8F8;
	}

	.container {
		width: 100%;
		height: 100%;
		padding: 0 20upx;
	}

	.first-item {
		margin: 20upx 0;
		border-radius: 5px;
		background-color: white;
		padding: 20upx;
		display: flex;
		flex-direction: row;
	}
</style>
